<extend name="Public:base" />
<block name="content">
	<div class="row-fluid">

		<div class="span12">
			
	            <div class="color-panel hidden-phone">

	                <div class="color-mode-icons icon-color"></div>

	                <div class="color-mode-icons icon-color-close" style="display: none;"></div>

	                <div class="color-mode" style="display: none;">

	                    <p>THEME COLOR</p>

	                    <ul class="inline">

	                        <li class="color-black color-default current" data-style="default"></li>

	                        <li class="color-blue" data-style="blue"></li>

	                        <li class="color-brown" data-style="brown"></li>

	                        <li class="color-purple" data-style="purple"></li>

	                        <li class="color-grey" data-style="grey"></li>

	                        <li class="color-white color-light" data-style="light"></li>

	                    </ul>

	                    <label>

	                        <span>Layout</span>

	                        <select class="layout-option m-wrap small">

	                            <option value="fluid" selected="">Fluid</option>

	                            <option value="boxed">Boxed</option>

	                        </select>

	                    </label>

	                    <label>

	                        <span>Header</span>

	                        <select class="header-option m-wrap small">

	                            <option value="fixed" selected="">Fixed</option>

	                            <option value="default">Default</option>

	                        </select>

	                    </label>

	                    <label>

	                        <span>Sidebar</span>

	                        <select class="sidebar-option m-wrap small">

	                            <option value="fixed">Fixed</option>

	                            <option value="default" selected="">Default</option>

	                        </select>

	                    </label>

	                    <label>

	                        <span>Footer</span>

	                        <select class="footer-option m-wrap small">

	                            <option value="fixed">Fixed</option>

	                            <option value="default" selected="">Default</option>

	                        </select>

	                    </label>

	                </div>

	            </div>

			<h3 class="page-title">

				Blog

				 <small>Blog文章管理和更多</small>

			</h3>

			<ul class="breadcrumb">

				<li>

					<i class="icon-home"></i>

					<a href="index.html">首页</a> 

					<span class="icon-angle-right"></span>

				</li>

				<li>

					<a href="/admin/blog/article/index">文章管理</a>

					<span class="icon-angle-right"></span>

				</li>

				<li><a href="/admin/blog/article/pinglun">文章评论</a></li>

			</ul>

		</div>

	</div>
	<!-- {:var_dump($art)} -->
	<!-- {:var_dump($res)} -->
	<!-- {:var_dump($data)} -->
	<!-- {:var_dump($huifu)} -->
		<img src="{$art['pic']}" style="width:100px;height:70px"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-size:30px;color:#003">{$art['title']}</span>
		<h3></h3>

		<if condition='($res eq null)'>
		<h1>&nbsp;</h1>
		<span style="color:pink;font-size:20px">此篇文章还没有人评论哦    快来抢沙发吧啊</span>
		<h1>&nbsp;</h1>		
		</if>
		<foreach name="res" item="vo">
			<div class="media">

				<a href="#" class="pull-left">

				<img alt="" style="width:50px;height:50px" src="{$vo['perpic']}" class="media-object">

				</a>

				<div class="media-body">

					<input type="hidden"  name="huifupinglunid" value="{$vo['id']}" />
					<input type="hidden"  name="pinglunid" value="{$vo['id']}" />

					<h4 class="media-heading">{$vo['name']}<!-- {$vo['id']} --> <span style="float:right">{$vo['c_time']}  / <a name="huifu" href="#">回复</a></span></h4>

					<p>{$vo['contents']}</p>
					<span style="float:right"><a name="del"  href="">删除</a></span>
					<h6>&nbsp;</h6>
					<hr>
					<foreach name="data" item="v">

						<if condition='($v["reid"] eq $vo["id"])'>

							<div class="media">

								<a href="#" class="pull-left">

								<img alt="" style="width:50px;height:50px" src="{$v['perpic']}" class="media-object">

								</a>

								<div class="media-body">
								<input type="hidden"  name="huifureplyid" value="{$v['id']}"/>
								<input type="hidden"  name="replyreid" value="{$v['reid']}"/>
									<h4 class="media-heading">{$v['name']}<!-- {$vo['id']} --> <span style="color:#669">回复</span>  {$vo['name']}<!--  恩恩{$v['id']} --><span style="float:right">{$v['c_time']}  / <a name="huifu" href="#">回复</a></span></h4>

									<p>{$v['contents']}</p>
									<span style="float:right"><a name="del" href="">删除</a></span>
									<h6>&nbsp;</h6>
									<hr>

									<foreach name="huifu" item="vv">

										<if condition='($vv["huifuid"] eq $v["id"])'>
										<!-- 啊啊啊啊啊 -->
											<div class="media">

												<a href="#" class="pull-left">

												<img alt="" style="width:50px;height:50px" src="{$vv['pic']}" class="media-object">

												</a>

												<div class="media-body">
													<h4 class="media-heading">{$vv['name']}  <span style="color:#669">回复</span>  {$vv['huifuname']}<span style="float:right">{$vv['c_time']}   <a href="#"></a></span></h4>

													<p>{$vv['contents']}</p>
													<input type="hidden" name="aa" value="{$vv['id']}"/>
													<span style="float:right"><a name="del" href="">删除</a></span>
													<h6>&nbsp;</h6>
													<hr>
												</div>

											</div>

										</if>
										
										
									</foreach>


								</div>

							</div>

						</if>
						
						
					</foreach>
	
				</div>

			</div>
		</foreach>

	<div class="post-comment">

		<h3>发表评论</h3>

			<input type="hidden" name="artid" value="{$art['id']}"/>
			<input type="hidden" name="uid" value="{:session('id')}"/>
			<input type="hidden" name="time" value="{:date('Y-m-d H:i:s',time())}"/>
			<label>评论内容</label>

			<textarea name="text" class="span10 m-wrap" rows="8"></textarea><span name="span" style="display:none;color:red">评论内容不能为空哦</span>

			<p><button name="fabiao" class="btn blue" type="submit">发表</button></p>

	</div>
	<div id="lvjing" style="display:none"></div>
    <div name="huifu" class="tianjia" style="display:none;height:300px;width:600px;left:350px;top:200px;">
        <h3 style="position:absolute;margin-left:125px;">回复评论</h3>
        <div class="portlet-body form">

            <div class="tabbable portlet-tabs">
                 <ul style="position:absolute;left:550px;z-index:200px;top:10px;" class="nav nav-tabs">

                      <li class=""><a href="#portlet_tab3" id="guanbi" data-toggle="tab">X</a></li>

                    

                 </ul>

                 <div class="tab-content">

                      <div class="tab-pane active" id="portlet_tab1">

                        

                           <form action="" if="myform" method="post" id="form" style="left:350px;top:300px" class="form-horizontal">
                               

                                 <div class="control-group">

                                     <label class="control-label"></label>

                                     <div class="controls">

                                            <textarea name="con" id="" xz="xz" cols="30" rows="6" style="resize:none;"></textarea>
                                          　<span name="con" class="help-inline" style="display:none"> 评论内容不能为空哦</span>

                                     </div>

                                </div>

                                
                                 <!--    <input type="submit" class="btn blue" style="margin-left:170px;" value='添加'> -->
                                     <button type="submit" id="tianjia" class="btn blue" style="margin-left:170px;"><i class="icon-ok"></i> 提交</button>
                                     <input type="reset" name="res" class="btn" style="margin-left:80px;" value="重置">
                                
                           </form>

                           <!-- END FORM-->  

                      </div>

                 </div>

            </div>

       </div>
    </div>


<script type="text/javascript" src="__PUBLIC__/admin/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
	$('button[name="fabiao"]').click(function(){
		// alert('aaa');	
		var text=$('textarea[name="text"]').val();
		var aid=$('input[name="artid"]').val();
		var uid=$('input[name="uid"]').val();
		var time=$('input[name="time"]').val();
		if(text==''){
			$('span[name="span"]').css('display','block');
		}else{
			$('span[name="span"]').css('display','none');
			$.ajax({
				url:'/admin/blog/article/pl',
				data:{'aid':aid,'uid':uid,'contents':text,'c_time':time},
				type:'post',
				success:function(mes){
					eval(mes);
				}
			});
		}

		return false;
	});
	var delpinglunid=null;
	var delreplyid=null;
	$('a[name="del"]').click(function(){
		// alert('del');
		// var pinglunid=$(this).parent().prevAll().eq('2').val();
		// var replyreid=
		// console.log(pinglunid);
		// $.ajax({
		// 	url:'/admin/blog/article/delpl',
		// 	data:{'delid':pinglunid},
		// 	type:'post',
		// 	success:function(mes){
		// 		console.log(mes);
		// 	}
		// });
		// console.log($(this).parent().prevAll().eq('2').attr('name'));

		var aid=$('input[name="artid"]').val();
		if($(this).parent().prevAll().eq('2').attr('name')=='pinglunid'){
			// console.log('pinglun');
			delpinglunid=null;delreplyid=null;
			delpinglunid=$(this).parent().prevAll().eq('3').val();
			// console.log(delpinglunid);
			$.ajax({
				url:'/admin/blog/article/delpl',
				data:{'aid':aid,'delpinglunid':delpinglunid},
				type:'post',
				success:function(mes){
					// console.log(mes);
					if(mes=='no'){
						if(confirm('该评论有回复信息 是否一并删除？')==true){
							// console.log('yes');
							$.ajax({
								url:'/admin/blog/article/delpl',
								data:{'aid':aid,'delpinglunidyes':delpinglunid},
								type:'post',
								success:function(mes){
									if(mes=='yes'){
										// $.ajax({
										// 	url:'/admin/blog/article/delpl',
										// 	data:{'replyyes':delpinglunid},
										// 	type:'post',
										// 	success:function(mes){
										// 		console.log(mes);
										// 	}
										// });
										eval(mes);
									}else{
										eval(mes);
									}
								}
							});
						}
					}else{
						eval(mes);
					}
				}
			});
		}else if($(this).parent().prevAll().eq('2').attr('name')=='replyreid'){
			// console.log('reply');
			delreplyid=null;delpinglunid=null;
			delreplyid=$(this).parent().prevAll().eq('3').val();
			var aid=$('input[name="artid"]').val();
			// console.log(delreplyid);
			$.ajax({
				url:'/admin/blog/article/delpl',
				data:{'delreplyid':delreplyid},
				type:'post',
				success:function(mes){
					if(mes=='no'){
						if(confirm('该评论有回复信息 是否一并删除？')==true){
							// console.log('yes');
							$.ajax({
								url:'/admin/blog/article/delpl',
								data:{'aid':aid,'delreplyidyes':delreplyid},
								type:'post',
								success:function(mes){
									eval(mes);
								}
							});
						}
					}
				}
			});
		}else{
			// console.log('huifu');
			var aa=$('input[name="aa"]').val();
			var aid=$('input[name="artid"]').val();
			// console.log(aa);
			$.ajax({
				url:'/admin/blog/article/delpl',
				data:{'aid':aid,'aa':aa},
				type:'post',
				success:function(mes){
					eval(mes);
				}
			});
		}




		return false;
	});
	var huifupinglunid=null;
	var huifureplyid=null;

	$('a[name="huifu"]').click(function(){
		// alert('huifu');
		// var aa=$(this).parent().parent().prevAll().eq('1').val();
		// console.log(aa);
		if($(this).parent().parent().prevAll().eq('1').attr('name')=='huifupinglunid'){
			huifupinglunid=null;huifureplyid=null;
			huifupinglunid=$(this).parent().parent().prevAll().eq('1').val();
		}else if($(this).parent().parent().prevAll().eq('1').attr('name')=='huifureplyid'){
			huifureplyid=null;huifupinglunid=null;
			huifureplyid=$(this).parent().parent().prevAll().eq('1').val();
		}
		$('#lvjing').css('display','block');
		$('div[name="huifu"]').css('display','block');

		return false;
	});
	$('#guanbi').click(function(){ 

		$('#lvjing').css('display','none');
		$('div[name="huifu"]').css('display','none');
		return false;
	});

	$('#tianjia').click(function(){
		// alert('aaa');
		var con=$('textarea[name="con"]').val();
		var uid=$('input[name="uid"]').val();
		var time=$('input[name="time"]').val();
		var aid=$('input[name="artid"]').val();
		if(huifupinglunid!=null){
			// console.log(huifupinglunid);
			if(con==''){
				$('span[name="con"]').css({'display':'block','color':'red'})
			}else{
				$('span[name="con"]').css({'display':'none'});
				$.ajax({
					url:'/admin/blog/article/huifu',
					data:{'aid':aid,'contents':con,'reid':huifupinglunid,'uid':uid,'c_time':time},
					type:'post',
					success:function(mes){
						eval(mes);
					}
				});
			}
		}else if(huifureplyid!=null){
			// console.log(huifureplyid);
			if(con==''){
				$('span[name="con"]').css({'display':'block','color':'red'})
			}else{
				$('span[name="con"]').css({'display':'none'});
				$.ajax({
					url:'/admin/blog/article/huifu',
					data:{'aid':aid,'contents':con,'huifuid':huifureplyid,'uid':uid,'c_time':time},
					type:'post',
					success:function(mes){
						eval(mes);
					}
				});
			}
		}
		return false;
	});

</script>


</block>
